@import "mixins/mixins";
@import "common/var";
@import "mixins/utils";

%size {
  width: 100%;
  height: 100%;
}

@include b(image) {
  position: relative;
  display: inline-block;
  overflow: hidden;

  @include e(inner) {
    @extend %size;
    vertical-align: top;

    @include m(center) {
      position: relative;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      display: block;
    }
  }

  @include e(placeholder) {
    @extend %size;
    background: $--background-color-base;
  }

  @include e(error) {
    @extend %size;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    background: $--background-color-base;
    color: $--color-text-placeholder;
    vertical-align: middle;
  }

  @include e(preview) {
    cursor: pointer;
  }
}


@include b(image-viewer) {


  @include e(wrapper) {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
  }

  @include e(top) {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 50px;
    padding: 0 20px;
    line-height: 50px;
    background-color: rgba(0,0,0,0.5);
    color: $--color-white;

    h4{
      display: inline-block;
      margin: 0;
      max-width: 80%;
      font-size: 16px;
      @include utils-ellipsis;
    }
    i{
      float: right;
      cursor: pointer;
      font-size: 14px;
    }
  }

  @include e(btn) {
    position: absolute;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    opacity: .8;
    cursor: pointer;
    box-sizing: border-box;
    user-select: none;
  }

  @include e(close) {
    top: 40px;
    right: 40px;
    width: 40px;
    height: 40px;
    font-size: 24px;
    color: #fff;
    background-color: #606266;
  }

  @include e(canvas) {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    width: 720px;
    height: 540px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: auto;
  }

  @include e(actions) {
    position: absolute;
    z-index: 1;
    left: 50%;
    bottom: 50px;
    transform: translateX(-50%);
    height: 50px;
    line-height: 50px;
    padding: 0 10px;
    background-color: #000;
    border-color: #fff;
    border-radius: 4px;

    // @include e(actions__inner) {
    //   width: 100%;
    //   height: 100%;
    //   text-align: justify;
    //   cursor: default;
    //   font-size: 23px;
    //   color: #fff;
    //   display: flex;
    //   align-items: center;
    //   justify-content: space-around;
    // }
    button{
      margin: 0 10px;
      padding: 0;
      outline: none;
      background-color: transparent;
      border: none;
      color: rgba(255,255,255,.6);
      line-height: 1;
      cursor: pointer;
      i{
        font-size: 18px;
        vertical-align: middle;
      }
      .download{
        margin-left: 8px;
        font-size: 14px;
        vertical-align: middle;
      }
      &:hover,&:active,&:focus{
        color: $--color-white;
      }

      &.btn-reset{
        width: 58px;
        padding: 5px 10px;
        font-size: 0;
        border-radius: 4px;
        text-align: center;
        vertical-align: middle;
        border: solid 2px rgba(255,255,255,.2);
        color: $--color-white;
        span{
          font-size: 18px;
        }
        &:hover{
          color: rgba(255,255,255,0.2);
          border-color: rgba(255,255,255,.2);
        }
        &:active,&:focus{
          color: $--color-white;
          border-color: $--color-white;
        }
      }
    }
  }

  @include e(prev){
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    font-size: 24px;
    color: #fff;
    background-color: rgba(0,0,0,0.5);
    border-color: #fff;
    left: 40px;
    i{
      font-size: 20px;
    }
    &:hover{
      background-color: #000;
    }
    &.is-disabled{
      background-color: rgba(0,0,0,0.3);
      color: rgba(255,255,255,0.3);
    }
  }

  @include e(next){
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    font-size: 24px;
    color: #fff;
    background-color: rgba(0,0,0,0.5);
    border-color: #fff;
    right: 40px;
    text-indent: 2px;
    i{
      font-size: 20px;
    }
    &:hover{
      background-color: #000;
    }
    &.is-disabled{
      background-color: rgba(0,0,0,0.3);
      color: rgba(255,255,255,0.3);
    }
  }

  @include e(mask) {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: .8;
    background: #000;
  }
}

.viewer-fade-enter-active {
  animation: viewer-fade-in .3s;
}

.viewer-fade-leave-active {
  animation: viewer-fade-out .3s;
}

@keyframes viewer-fade-in {
  0% {
    transform: translate3d(0, -20px, 0);
    opacity: 0;
  }
  100% {
    transform: translate3d(0, 0, 0);
    opacity: 1;
  }
}

@keyframes viewer-fade-out {
  0% {
    transform: translate3d(0, 0, 0);
    opacity: 1;
  }
  100% {
    transform: translate3d(0, -20px, 0);
    opacity: 0;
  }
}
